define(['./FloatRect'], function(FloatRect) {
	var FormWidget = function() {
		this.fieldAction = {};
		this.rect = new FloatRect();
		this.borderWidth = 0;
        this.fontSize = 12;
        this.bReadOnly = false;
        this.bRequired = false;
        this.onfocus = false;
        this._formatters = [];
        this._validater = [];
        this.value = "";
	};

	FormWidget.prototype.addValidater = function(func){
		this._formatters.push(func);
	};

	FormWidget.prototype.addFormatter = function(func){
		this._formatters.push(func);
	};

	FormWidget.prototype.validateInputValue = function(inputValue, element) {
        var isValidate = true;
        angular.forEach(this._validater, function(validateFunc, key) {            
            isValidate = validateFunc(inputValue, element);
            if (isValidate !== true) return !!isValidate;            
        });
        return isValidate;    
    };

    FormWidget.prototype.formateViewValue = function(srcValue) {      
        var viewValue = srcValue;       
        angular.forEach(this._formatters, function(formateFunc, key) {
            if (key === 0) {
                viewValue = formateFunc(viewValue);
            } else {
                viewValue = formateFunc(viewValue);
            }
        });              
       
        return viewValue;       
    };

	return FormWidget;
});